//package com.job.common.util;
//
//
//import com.job.common.result.ResultCodeEnum;
//import io.jsonwebtoken.*;
//import io.jsonwebtoken.security.Keys;
//import jakarta.annotation.PostConstruct;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import javax.crypto.SecretKey;
//import java.util.Date;
//
//@Component
//public class JwtUtil {
//
//
//    private static long tokenExpiration = 24*60 * 60 * 1000L;
//
//    @Value("${jwt.secret}")
//    private  String secret;
//    private static SecretKey tokenSignKey;
//    @PostConstruct
//    public void init() {
//        tokenSignKey = Keys.hmacShaKeyFor(secret.getBytes());
//    }
//
//    public static String createToken(Long userId, String username, Long roleId) {
//        String token = Jwts.builder().
//                setSubject("USER_INFO").
//                setExpiration(new Date(System.currentTimeMillis() + tokenExpiration)).
//                claim("userId", userId).
//                claim("username", username).
//                claim("roleId",roleId).
//                signWith(tokenSignKey).
//                compact();
//        return token;
//    }
//
////    public  Claims parseToken(String token) {
////        try {
////            Jws<Claims> claimsJws = Jwts.parserBuilder().
////                    setSigningKey(tokenSignKey).
////                    build().parseClaimsJws(token);
////            return claimsJws.getBody();
////
////        } catch (ExpiredJwtException e) {
////            throw new LeaseException(ResultCodeEnum.TOKEN_EXPIRED);
////        } catch (JwtException e) {
////            throw new LeaseException(ResultCodeEnum.TOKEN_INVALID);
////        }
////    }
//
//
//}